<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>词多多代理商平台</title>
    <include file="Index:header"/>
    <!----自动提示的input引入文件开始---------->
    <link rel="stylesheet" href="__PUBLIC__/css/textext.core.css" type="text/css" />
    <link rel="stylesheet" href="__PUBLIC__/css/textext.plugin.autocomplete.css" type="text/css" />
    <link rel="stylesheet" href="__PUBLIC__/css/textext.plugin.prompt.css" type="text/css" />
    <script src="__PUBLIC__/js/textext.core.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/textext.plugin.autocomplete.js" type="text/javascript" charset="utf-8"></script>
    <script src="__PUBLIC__/js/textext.plugin.prompt.js" type="text/javascript" charset="utf-8"></script>
    <!----自动提示的input引入文件结束---------->
    <script type="text/javascript">
        $(function(){
            $(".help-side dl dd:eq(0)").addClass('cur');
        })
        $(function(){
            $("#top #topcon .nav li:eq(2)").addClass('cur');
        }) 
    </script>
    <script src="__PUBLIC__/js/main.js" type="text/javascript" charset="UTF-8"></script>
</head>

<body>
    <include file="Index:top"/>
    <div id="main" style="overflow:visible">
        <include file="Site:left"/>
        <div id="main_right" class="container">
            <div class="title">站点列表</div>
            <div id="infotab" class="container mt10">
                <ul class="tb cl">
                    <if condition="$_GET['status'] eq 'off'">
                        <li>
                            <a href="{:U(index)}">开启状态</a>
                        </li>
                        <li class="a">
                            <a href="{:U('?status=off')}">暂停状态</a>
                        </li>
                        <else/>
                        <li class="a">
                            <a href="{:U(index)}">开启状态</a>
                        </li>
                        <li>
                            <a href="{:U('?status=off')}">暂停状态</a>
                        </li>
                    </if>
                </ul>

                <div class="container p10 mr10 ml10">
                    <table class="tableStyle">
                        <tr>
                            <td width="60px" style="padding-left: 30px;">用户名</td>
                            <td>
                                <input id="textarea" type="text" name="name" class="input" style="width:120px; z-index:100;" onkeydown="enterPress(event)"/>
                            </td>
                            <td width="40px" style="padding-left: 170px;">站点</td>
                            <td>
                                <div id="domain" class="dropdown" tabIndex="1">
                                    <select name="domain" style="height:30px;width:150px;" id="site">
                                        <option value="">请选择站点</option>
                                    </select>
                                </div>
                            </td>
                            <if condition="$_GET['status'] eq 'off'">
                                <td style="padding-left: 20px;">
                                    <input class="button_s green" type="submit" name="button" id="button" onclick="query1();" value="查&nbsp;&nbsp;询" />
                                </td>
                                <else/>
                                <td style="padding-left: 20px;">
                                    <input class="button_s green" type="submit" name="button" id="button" onclick="query();" value="查&nbsp;&nbsp;询" />
                                </td>
                            </if>
                        </tr>
                    </table>
                </div>

                <table class="table mr10 ml10" cellpadding=4>
                    <tr style="border-bottom: 2px solid #eee;">
                        <th width="20%">站点</th>
                        <th width="35%">站点名称</th>
                        <th width="7%">用户名</th>
                        <th width="15%">关键词数量(个)</th>
                        <th width="7%">状态</th>
                        <th width="10%">操作</th>
                    </tr>

                    <tbody id="tbody">
                        <volist name="list" id="vo">
                            <tr>
                                <td>
                                    <a href="http://{$vo['Domain']}" target="_blank">{$vo['Domain']}</a>
                                </td>
                                <td>{$vo['Webname']|msubstr=0,15,'utf-8',false}</td>
                                <td>{$vo['Username']}</td>
                                <td style="padding-left:40px">{$vo['k_num']}</td>
                                <if condition="$vo[Status] eq ON">
                                    <td>开启</td>
                                    <else/>
                                    <td>暂停</td>
                                </if>
                                <td>
                                    <div class="menubox">
                                        <div class="mainmenu">
                                            <div class="category">
                                                <span class="tit">操作选项</span>
                                                <ul class="submenu">
                                                    <li>
                                                        <a href="__URL__/site_info/id/{$vo[Id]}">
                                                            <span class='ico ico_world_edit'></span>
                                                            站&nbsp;点&nbsp;详&nbsp;情
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="javascript:void(0)" onclick="xptj();">
                                                            <span class='ico ico_world_link'></span>
                                                            询&nbsp;盘&nbsp;统&nbsp;计
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="javascript:void(0)" onclick="location='__URL__/site_keyword/id/{$vo[Id]}'">
                                                            <span class='ico ico_orbit'></span>
                                                            站点关键词
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="javascript:void(0)" onclick="location='__URL__/site_keyword_add/id/{$vo[Id]}'">
                                                            <span class='ico ico_add'></span>
                                                            添加关键词
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <if condition="$vo[Status] eq ON">
                                                            <a href="javascript:void(0)" onclick="pause('__URL__/site_stop',{$vo[Id]});">
                                                                <span class="ico ico_control_stop_blue"></span>
                                                                暂&nbsp;停&nbsp;站&nbsp;点
                                                            </a>
                                                            <else/>
                                                            <a href="javascript:void(0)" onclick="start('__URL__/site_start',{$vo['Id']});">
                                                                <span class="ico ico_control_play_blue"></span>
                                                                开&nbsp;启&nbsp;站&nbsp;点
                                                            </a>
                                                        </if>
                                                    </li>
                                                    <li>
                                                        <a href="javascript:void(0)" onclick="del('__URL__/site_del',{$vo['Id']});">
                                                            <span class="ico ico_cross"></span>
                                                            删&nbsp;除&nbsp;站&nbsp;点
                                                        </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </volist>
                    </tbody>
                </table>
                <div class="mt10">
                    <div class="page_list">
                        <div class="p_l">{$pageshow}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<!--     <include file="Index:footer"/> -->
    <script>

        function usersite(){
            userName=$("#textarea").val();
            if(userName==""){
                msgwarn("如要查询请先输入用户名");
                return false;
            }
            get_url = "__APP__/User/usersites";
            $.ajax({
                url:get_url,
                type:'POST',
                data:{'userName':userName},
                cache:false,
                dataType:"json",
                success:function(data){
                    if(data.status =='true'){
                        $("#site option:gt(0)").remove();
                        $.each(data,function(n,value){
                            if(value!='true'){
                                $("#site").append("<option value="+value+">"+value+"</option>");
                            }
                        });
                    }else{
                        msgwarn(data.Msg);
                    }
                }
            });
        }
        $("#textarea").blur(function(){
            setTimeout("usersite()",200);
        });

        function enterPress(e) {
            if (e.keyCode == 13) {
                setTimeout("usersite()",200);
            }
        }

        function query(){
            userName=$("#textarea").val();
            site = $(".dropselectbox h4").text();
            if(userName==""){
                msgwarn("请填写用户名");
                return false;
            }

            if(site==""){
                msgwarn("请选择站点");
                return false;
            }

            window.location="__URL__/index?userName="+userName+"&site="+site;
        }

        function query1(){
            userName=$("#textarea").val();
            site = $(".dropselectbox h4").text();

            if(userName==""){
                msgwarn("请填写用户名");
                return false;
            }

            if(site==""){
                msgwarn("请选择站点");
                return false;
            }

            window.location="__URL__/index?status=off&userName="+userName+"&site="+site;
        }        

        function xptj() {
            art.dialog.open("{:U('site_xptj')}", {
                title: '询盘统计',
                lock: 'true',
                width:720,
                height:300
            });
        }       

        function test() {
            art.dialog.open('welcome.html', {
                title: '询盘统计',
                lock: 'true',
                width:900,
                height:500
            });
        }  

        $(function() {
            $("#domain").sSelect();
            $("#domain").click(function(){
                var name = $('#textarea').val();
                $.ajax({
                    url:"{:U('site_list')}",
                    type:"POST",
                    data:{'name':name},
                    cache:false,
                    dataType:"json"
                });
            });
        });

        function hash(str, hashSize)
            {
                var result = 0;
                for(var i = 0; i < str.length; i++)
                    result += str.charCodeAt(i) + 31 * result;
                return result % hashSize;
            }

            $('#textarea')
                .textext({
                    plugins : 'autocomplete',
                    autocomplete : {
                        dropdownMaxHeight : '200px',

                        render : function(suggestion)
                        {
                            var icons = 'exclamation feed house information lock'.split(/ /g),
                                    icon  = icons[hash(suggestion, icons.length)];
                            return  suggestion
                        }
                    }
                })
                .bind('getSuggestions', function(e, data)
                {
                    var list = [{$username}
                            ],
                            textext = $(e.target).textext()[0],
                            query = (data ? data.query : '') || '';

                    $(this).trigger(
                            'setSuggestions',
                            { result : textext.itemManager().filter(list, query) }
                );
            });
    </script></body>
</html>